<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../../jeasyui/themes/gray/easyui.css" />
<link rel="stylesheet" type="text/css" href="../../jeasyui/themes/icon.css" />
<link rel="stylesheet" type="text/css" href="../../css/manager.css" />

<script type="text/javascript" src="../../jeasyui/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="../../jeasyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../../jeasyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../../js/win.js"></script>
<title>导航管理</title>
<style type="text/css">
	.nav-tree{
		width: 190px;
		padding: 10px 0 0 10px;
	}
</style>
<script type="text/javascript">

	var level = 1;
	var id = 0;
	var type = 2;

	function initNavTree(){
		$("#navTree").tree({
			url:'nav.do?method=navTree',
			onClick: function(node){
				if(node.attributes.level == 0){
					level = 1;
					id = 0;
					type = node.attributes.type;
					loadDatagrid();
				} else if(node.attributes.level == 1){
					level = 2;
					id = node.id;
					type = node.attributes.type;
					loadDatagrid();
				}
			}
		});
	}

	function addNav(){
		openUrl("新增导航", 450, 330, "addNav.jsp?level="+level+"&parentId="+id+"&type="+type);
	}

	function editNav(){
		selectOneOpenUrl("#dg","nav.do?method=initEdit", 450, 330, "修改", "导航");
	}

	function deleteNav(){
		checkSelectSomeDoAction("#dg", "删除", "导航", "nav.do?method=delSome", true, reloadTree);
	}

	function reloadTree(){
		$('#navTree').tree('reload');
	}
	
	function reloadDg(){
		$("#dg").datagrid("reload");
		reloadTree();
		closeWin();
	}

	function loadDatagrid(){
		$('#dg').datagrid('reload', {level:level, id:id, type:type});
	}

	function initDg(){
	 $('#dg').datagrid({
        url:'nav.do?method=levelNavs',
        queryParams: {
        	level: 1,
        	id:0,
        	type:2
    	}
    });
	}
	$(function(){
		initNavTree();
		initDg();
	});
</script>
</head>
<body class="easyui-layout">
<div data-options="region:'west',border:true" class="nav-tree" style="border-top: none;border-left: none;border-bottom: none;">
	<ul class="easyui-tree" id="navTree"></ul>
</div>
<div data-options="region:'center',border:false">
<div class="dg-content">
		<table id="dg" title="导航列表"
			data-options="rownumbers:true,fitColumns:true,iconCls:'icon-users'">
			<thead>
				<tr>
					<th data-options="field:'ck',checkbox:true"></th>
					<th data-options="field:'id',hidden:true"></th>
					<th data-options="field:'name',width:80,align:'center'">名称</th>
					<th data-options="field:'url',width:100,align:'center'">地址</th>
					<th data-options="field:'level',width:60,align:'center'">级别</th>
					<th data-options="field:'type',width:60,align:'center'">类型</th>
					<th data-options="field:'remark',width:60,align:'center'">说明</th>
				</tr>
			</thead>
		</table>
	</div>
	<div class="dg-foot">
		<div class='dg-toolbar'>
			<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="addNav()">新增</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editNav()">修改</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="deleteNav()">删除</a>
		</div>
	</div>
	</div>
</body>
</html>